/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.Equity;
import edu.cmu.mism.dgjava.data.models.option.OptionModelPackage;

import java.util.Map;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Equity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.EquityImpl#getStockPrice <em>Stock Price</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.EquityImpl#getDividends <em>Dividends</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EquityImpl extends DerivitivesImpl implements Equity {
	/**
	 * The default value of the '{@link #getStockPrice() <em>Stock Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStockPrice()
	 * @generated
	 * @ordered
	 */
	protected static final double STOCK_PRICE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getStockPrice() <em>Stock Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStockPrice()
	 * @generated
	 * @ordered
	 */
	protected double stockPrice = STOCK_PRICE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getDividends() <em>Dividends</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDividends()
	 * @generated
	 * @ordered
	 */
	protected Map<Double, Double> dividends;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EquityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OptionModelPackage.Literals.EQUITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getStockPrice() {
		return stockPrice;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStockPrice(double newStockPrice) {
		double oldStockPrice = stockPrice;
		stockPrice = newStockPrice;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.EQUITY__STOCK_PRICE, oldStockPrice, stockPrice));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Map<Double, Double> getDividends() {
		return dividends;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDividends(Map<Double, Double> newDividends) {
		Map<Double, Double> oldDividends = dividends;
		dividends = newDividends;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.EQUITY__DIVIDENDS, oldDividends, dividends));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OptionModelPackage.EQUITY__STOCK_PRICE:
				return getStockPrice();
			case OptionModelPackage.EQUITY__DIVIDENDS:
				return getDividends();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OptionModelPackage.EQUITY__STOCK_PRICE:
				setStockPrice((Double)newValue);
				return;
			case OptionModelPackage.EQUITY__DIVIDENDS:
				setDividends((Map<Double, Double>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OptionModelPackage.EQUITY__STOCK_PRICE:
				setStockPrice(STOCK_PRICE_EDEFAULT);
				return;
			case OptionModelPackage.EQUITY__DIVIDENDS:
				setDividends((Map<Double, Double>)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OptionModelPackage.EQUITY__STOCK_PRICE:
				return stockPrice != STOCK_PRICE_EDEFAULT;
			case OptionModelPackage.EQUITY__DIVIDENDS:
				return dividends != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (stockPrice: ");
		result.append(stockPrice);
		result.append(", dividends: ");
		result.append(dividends);
		result.append(')');
		return result.toString();
	}

} //EquityImpl
